using System.Windows.Forms;
using OFX.Aggregator.WebScraping.Infrastructure;

namespace OFX.Aggregator.WebScraping.Implementation.BESnet.HtmlPageProcessing
{
	public class BESnetHomePageProcessor : IHtmlPageProcessor
	{
		public string UserName { get; set; }

		#region Implementation of IHtmlPageProcessor

		public void TestAssumptions(IHtmlDocument document)
		{
			IHtmlElement fca = document.GetElementById("fca");
			if (fca == null)
			{
				throw new AssumptionFailedException(this, "Expected 'fca' element not found in page!");
			}
		}

		public void ProcessPage(IHtmlDocument document, IHtmlPageProcessorFinished finished)
		{
			IHtmlElement fca = document.GetElementById("fca");

			fca.Focus();
			SendKeys.SendWait(this.UserName);
		}

		#endregion
	}
}